﻿#include "adminmodifycourseinfo.h"
#include "ui_adminmodifycourseinfo.h"
#include "mainwindow.h"
adminModifyCourseInfo::adminModifyCourseInfo(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::adminModifyCourseInfo)
{
    ui->setupUi(this);
}

adminModifyCourseInfo::~adminModifyCourseInfo()
{
    delete ui;
}

void adminModifyCourseInfo::getOldInfo(QStringList oldInfo)
{
    ui->edit_select_id->setText(oldInfo.at(0));
    ui->edit_course_id->setText(oldInfo.at(1));
    ui->edit_course_name->setText(oldInfo.at(2));
    ui->spin_class->setValue(oldInfo.at(3).toInt());
    ui->spin_credit->setValue(oldInfo.at(4).toInt());
    ui->box_course_charactor->setCurrentText(oldInfo.at(5));
    ui->edit_college->setText(oldInfo.at(6));
    ui->edit_teacher->setText(oldInfo.at(7));
    ui->edit_level->setText(oldInfo.at(8));
    ui->box_course_time_1->setCurrentText(oldInfo.at(9).mid(0,2));
    ui->box_course_time_2->setCurrentText(oldInfo.at(9).mid(2,5));
    ui->box_course_school->setCurrentText(oldInfo.at(10));
    ui->spin_max_people->setValue(oldInfo.at(11).toInt());

}

QStringList adminModifyCourseInfo::getNewInfo()
{
    return newInfo;
}

void adminModifyCourseInfo::clearUi()
{
    ui->edit_select_id->clear();
    ui->edit_course_id->clear();
    ui->edit_course_name->clear();
    ui->spin_class->setValue(0);
    ui->spin_credit->setValue(0);
    ui->box_course_charactor->setCurrentIndex(0);
    ui->edit_college->clear();
    ui->edit_teacher->clear();
    ui->edit_level->clear();
    ui->box_course_time_1->setCurrentIndex(0);
    ui->box_course_time_2->setCurrentIndex(0);
    ui->box_course_school->setCurrentIndex(0);
    ui->spin_max_people->setValue(0);
    newInfo.clear();
    newInfo.append("0");
}

void adminModifyCourseInfo::on_btn_confirm_2_clicked()
{
    newInfo.clear();
    newInfo.append(ui->edit_select_id->text());
    newInfo.append(ui->edit_course_id->text());
    newInfo.append(ui->edit_course_name->text());
    newInfo.append(ui->spin_class->text());
    newInfo.append(ui->spin_credit->text());
    newInfo.append(ui->box_course_charactor->currentText());
    newInfo.append(ui->edit_college->text());
    newInfo.append(ui->edit_teacher->text());
    newInfo.append(ui->edit_level->text());
    newInfo.append(ui->box_course_time_1->currentText()+ui->box_course_time_2->currentText());
    newInfo.append(ui->box_course_school->currentText());
    newInfo.append(ui->spin_max_people->text());
    this->close();
}

void adminModifyCourseInfo::on_btn_exit_check_clicked()
{
    this->close();
}
